﻿<TextBox x:Class="AurelienRibon.Ui.SyntaxHighlightBox.SyntaxHighlightBox"
		xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:local="clr-namespace:AurelienRibon.Ui.SyntaxHighlightBox" TextWrapping="NoWrap" Foreground="#00000000">

	<TextBox.Style>
		<Style TargetType="{x:Type local:SyntaxHighlightBox}">
			<Setter Property="AcceptsReturn" Value="True" />
			<Setter Property="AcceptsTab" Value="True" />
			<Setter Property="HorizontalScrollBarVisibility" Value="Auto" />
			<Setter Property="VerticalScrollBarVisibility" Value="Auto" />
			<Setter Property="FontFamily" Value="Courier New" />
			<Setter Property="FontSize" Value="9pt" />
		</Style>
	</TextBox.Style>

	<TextBox.Template>
		<ControlTemplate TargetType="{x:Type local:SyntaxHighlightBox}">
			<!--Visual-->
			<Border Background="White" BorderThickness="{TemplateBinding BorderThickness}"
					BorderBrush="{TemplateBinding BorderBrush}">
				<Grid>
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="auto" />
						<ColumnDefinition Width="auto" />
						<ColumnDefinition />
					</Grid.ColumnDefinitions>

					<local:DrawingControl x:Name="PART_LineNumbersCanvas" Grid.Column="0" ClipToBounds="True" />

					<Line Grid.Column="1" Margin="2,0,5,0" Stroke="Gray" StrokeThickness="1" Y2="1" Stretch="Fill"
							StrokeDashArray="1,1" RenderOptions.EdgeMode="Aliased" x:Name="lineNumbersSeparator" />

					<Grid Grid.Column="2">
						<!--Render canvas-->
						<Grid Margin="{TemplateBinding Padding}">
							<local:DrawingControl x:Name="PART_RenderCanvas" ClipToBounds="True"
									TextOptions.TextRenderingMode="ClearType" TextOptions.TextFormattingMode="Display" />
						</Grid>
						<!--Transparent input textbox-->
						<ScrollViewer x:Name="PART_ContentHost" Background="#00FFFFFF" />

					</Grid>

				</Grid>
			</Border>

			<!--Triggers-->
			<ControlTemplate.Triggers>
				<Trigger Property="IsLineNumbersMarginVisible" Value="false">
					<Setter TargetName="PART_LineNumbersCanvas" Property="Visibility" Value="Collapsed" />
					<Setter TargetName="lineNumbersSeparator" Property="Visibility" Value="Collapsed" />
				</Trigger>
			</ControlTemplate.Triggers>
		</ControlTemplate>
	</TextBox.Template>

</TextBox>
